home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / bbs / termv4.6 / extras / source / gtlayout-source.lha / LT_HandleInput.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-18  |  48.6 KB  |  2,157 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. */
  7.  
  8. #ifndef _GTLAYOUT_GLOBAL_H
  9. #include "gtlayout_global.h"
  10. #endif
  11.  
  12. /*#define GT_SetGadgetAttrs Dummy*/
  13.  
  14. /*extern void Dummy(...);*/
  15.  
  16. /****** gtlayout.library/LT_HandleInput ******************************************
  17. *
  18. *   NAME
  19. *    LT_HandleInput -- Filter IntuiMessage data.
  20. *
  21. *   SYNOPSIS
  22. *    LT_HandleInput(Handle,Qualifier,Class,Code,Gadget);
  23. *                     A0      A1      A2    A2    A3
  24. *
  25. *    VOID LT_HandleInput(LayoutHandle *,ULONG,ULONG *,
  26. *                        UWORD *,struct Gadget **);
  27. *
  28. *   FUNCTION
  29. *    In order to keep track of user interface actions, such as
  30. *    keys getting pressed, sliders getting moved, etc. your
  31. *    code is to call LT_HandleInput() with data copied from the
  32. *    IntuiMessage it has just received and replied.
  33. *
  34. *   INPUTS
  35. *    Handle - Pointer to a LayoutHandle structure.
  36. *
  37. *    Qualifier - The Qualifier value copied from the
  38. *        IntuiMessage structure.
  39. *
  40. *    Class - Pointer to the ULONG variable which holds the
  41. *        value copied from the Class entry of the
  42. *        IntuiMessage structure.
  43. *
  44. *    Code - Pointer to the UWORD variable which holds the
  45. *        value copied from the Code entry of the
  46. *        IntuiMessage structure.
  47. *
  48. *    Gadget - Pointer to the Gadget value copied from the
  49. *        IAddress entry of the IntuiMessage structure.
  50. *
  51. *   RESULT
  52. *    none
  53. *
  54. *   EXAMPLE
  55. *    struct IntuiMessage *IntuiMessage;
  56. *    ULONG Qualifier,Class;
  57. *    UWORD Code;
  58. *    struct Gadget *Gadget;
  59. *
  60. *    for(;;)
  61. *    {
  62. *        WaitPort(Window -> UserPort);
  63. *
  64. *        while(IntuiMessage = GT_GetIMsg(Window -> UserPort))
  65. *        {
  66. *            Class = IntuiMessage -> Class;
  67. *            Code = IntuiMessage -> Code;
  68. *            Qualifier = IntuiMessage -> Qualifier;
  69. *            Gadget = IntuiMessage -> Gadget;
  70. *
  71. *            GT_ReplyIMsg(IntuiMessage);
  72. *
  73. *            LT_HandleInput(Handle,Qualifier,&Class,&Code,&Gadget);
  74. *        }
  75. *    }
  76. *
  77. *   NOTES
  78. *    For BOOPSI_KIND objects keystroke activation may lead to
  79. *    unexpected results. Your application will hear a IDCMP_GADGETUP
  80. *    event, the IntuiMessage->Code value will hold the ANSI key
  81. *    code of the key the user pressed.
  82. *
  83. *    Do not call this routine before you have actually
  84. *    replied the IntuiMessage received or weird things
  85. *    may happen. This is not a suggestion, it's a threat.
  86. *
  87. ******************************************************************************
  88. *
  89. */
  90.  
  91. VOID LIBENT
  92. LT_HandleInput(_REG(a0) LayoutHandle *Handle,_REG(d0) ULONG MsgQualifier,_REG(a1) ULONG *MsgClass,_REG(a2) UWORD *MsgCode,_REG(a3) struct Gadget **MsgGadget)
  93. {
  94.     ObjectNode    *Node;
  95.     BOOL          Activate = FALSE;
  96.  
  97.     if(!Handle)
  98.         return;
  99.  
  100.     if(Handle -> Failed)
  101.     {
  102.         *MsgClass = IDCMP_CLOSEWINDOW;
  103.  
  104.         if(!Handle -> NeedDelay)
  105.             Handle -> NeedDelay = TRUE;
  106.         else
  107.             LTP_Delay(0,500000);    // Give the guy a break
  108.  
  109.         return;
  110.     }
  111.  
  112.     switch(*MsgClass)
  113.     {
  114.         case IDCMP_CHANGEWINDOW:
  115.  
  116.             if(!(Handle -> Window -> Flags & WFLG_SIZEGADGET) && (Handle -> Window -> Flags & WFLG_HASZOOM) && !V39)
  117.             {
  118. #ifdef DO_BOOPSI_KIND
  119.                 if(Handle -> BOOPSIList)
  120.                     RefreshGList((struct Gadget *)Handle -> BOOPSIList,Handle -> Window,NULL,(UWORD)-1);
  121. #endif    /* DO_BOOPSI_KIND */
  122.  
  123.                 RefreshGList(Handle -> List,Handle -> Window,NULL,(UWORD)-1);
  124.  
  125.                 GT_RefreshWindow(Handle -> Window,NULL);
  126.  
  127.                 LTP_DrawGroup(Handle,Handle -> TopGroup);
  128.             }
  129.  
  130.             break;
  131.  
  132.         case IDCMP_NEWSIZE:
  133.  
  134.                 // Did the user cancel the resize operation?
  135.  
  136.             if(Handle -> SizeVerified && Handle -> SizeWidth == Handle -> Window -> Width && Handle -> SizeHeight == Handle -> Window -> Height)
  137.             {
  138.                 Handle -> SizeVerified    = FALSE;
  139.                 Handle -> SizeWidth    = 0;
  140.                 Handle -> SizeHeight    = 0;
  141.  
  142.                     // Put the gadgets back in
  143.  
  144.                 AddGList(Handle -> Window,Handle -> List,(UWORD)-1,(UWORD)-1,NULL);
  145.             }
  146.             else
  147.             {
  148.                 struct IBox Box;
  149.  
  150.                 Handle -> SizeWidth    = 0;
  151.                 Handle -> SizeHeight    = 0;
  152.  
  153.                 Box . Left    = 0;
  154.                 Box . Top    = 0;
  155.                 Box . Width    = Handle -> Window -> Width;
  156.                 Box . Height    = Handle -> Window -> Height;
  157.  
  158.                 LT_LockWindow(Handle -> Window);
  159.  
  160.                 if(Handle -> ResizeView)
  161.                     Handle -> ResizeView -> Special . List . IgnoreListContents = TRUE;
  162.  
  163.                 LT_RebuildTags(Handle,TRUE,
  164.                     LAWN_Bounds,    &Box,
  165.                 TAG_DONE);
  166.  
  167.                 LT_UnlockWindow(Handle -> Window);
  168.  
  169.                 if(Handle -> Failed)
  170.                     *MsgClass = IDCMP_CLOSEWINDOW;
  171.                 else
  172.                     *MsgClass = NULL;
  173.             }
  174.  
  175.             break;
  176.  
  177.         case IDCMP_REFRESHWINDOW:
  178.  
  179.             if(Handle -> AutoRefresh)
  180.             {
  181.                 LT_BeginRefresh(Handle);
  182.  
  183.                 LT_EndRefresh(Handle,TRUE);
  184.  
  185.                 *MsgClass = NULL;
  186.             }
  187.  
  188.             break;
  189.  
  190.         case IDCMP_INTUITICKS:
  191.  
  192.             if(Handle -> ActiveIncrementer)
  193.             {
  194.                 if(Handle -> IncrementerCountdown > 0)
  195.                     Handle -> IncrementerCountdown--;
  196.  
  197.                 if(Handle -> IncrementerCountdown <= 0)
  198.                 {
  199.                     if(Handle -> ActiveIncrementer -> Host -> Flags & GFLG_SELECTED)
  200.                     {
  201.                         if(Handle -> ActiveIncrementer -> Type == TAPEDECK_KIND)
  202.                         {
  203.                             *MsgClass    = IDCMP_GADGETUP;
  204.                             *MsgCode    = 0;
  205.                             *MsgGadget    = Handle -> ActiveIncrementer -> Host;
  206.                         }
  207.                         else
  208.                         {
  209.                             struct ObjectNode    *Parent;
  210.                             LONG             Number;
  211.  
  212.                             if(Handle -> IncrementerAccelerate > 0 && !(MsgQualifier & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)))
  213.                                 Handle -> IncrementerAccelerate--;
  214.  
  215.                             if(Handle -> IncrementerAccelerate <= 0)
  216.                             {
  217.                                 Handle -> IncrementerAccelerate = 10;
  218.  
  219.                                 Handle -> IncrementerIncrement *= 2;
  220.                             }
  221.  
  222.                             *MsgClass    = IDCMP_GADGETUP;
  223.                             *MsgCode    = 0;
  224.                             *MsgGadget    = Handle -> ActiveIncrementer -> Special . Incrementer . Parent;
  225.  
  226.                             Parent = (*MsgGadget) -> UserData;
  227.  
  228.                             if(Parent -> Special . Integer . IncrementerHook)
  229.                                 Number = CallHookPkt(Parent -> Special . Integer . IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE),Handle -> ActiveIncrementer -> Special . Incrementer . Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  230.                             else
  231.                                 Number = ((LONG)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE)) + Handle -> ActiveIncrementer -> Special . Incrementer . Amount * Handle -> IncrementerIncrement;
  232.  
  233.                             if(Number < Parent->Min)
  234.                                 Number = Parent->Min;
  235.                             else
  236.                             {
  237.                                 if(Number > Parent->Max)
  238.                                     Number = Parent->Max;
  239.                             }
  240.  
  241.                             LT_SetAttributes(Handle,Parent -> ID,
  242.                                 LAPR_Object,    Parent,
  243.                                 GTIN_Number,    Number,
  244.                             TAG_DONE);
  245.                         }
  246.                     }
  247.                     else
  248.                     {
  249.                         Handle -> IncrementerIncrement    = 1;
  250.                         Handle -> IncrementerAccelerate    = 10;
  251.                     }
  252.  
  253.                     if(Handle -> IncrementerIncrement == 1)
  254.                         Handle -> IncrementerCountdown = 2;
  255.                 }
  256.             }
  257.  
  258.             break;
  259.  
  260.         case IDCMP_RAWKEY:
  261.         {
  262.             UBYTE            Buffer[10];
  263.             LONG            Key;
  264.             struct InputEvent    event;
  265.             BOOL             KeyUp;
  266.  
  267.             if((*MsgCode & ~IECODE_UP_PREFIX) == 95 && Handle -> HelpHook)
  268.             {
  269.                 if(!(*MsgCode & IECODE_UP_PREFIX))
  270.                 {
  271.                     ObjectNode    *Item;
  272.                     struct HelpMsg     Message;
  273.                     struct IBox     Box;
  274.  
  275.                     Item = LTP_FindNode_Position(Handle -> TopGroup,Handle -> Window -> MouseX,Handle -> Window -> MouseY);
  276.  
  277.                     if(Item == Handle -> TopGroup)
  278.                     {
  279.                         if(Item -> ID <= PHANTOM_GROUP_ID)
  280.                             Item = NULL;
  281.                     }
  282.  
  283.                     if(Item)
  284.                     {
  285.                         Message . ObjectID = Item -> ID;
  286.  
  287.                         Box . Left    = Item -> Left;
  288.                         Box . Top    = Item -> Top;
  289.                         Box . Width    = Item -> Width;
  290.                         Box . Height    = Item -> Height;
  291.                     }
  292.                     else
  293.                     {
  294.                         Message . ObjectID = -1;
  295.  
  296.                         Box . Left    = 0;
  297.                         Box . Top    = 0;
  298.                         Box . Width    = Handle -> Window -> Width;
  299.                         Box . Height    = Handle -> Window -> Height;
  300.                     }
  301.  
  302.                     Message . Handle = Handle;
  303.  
  304.                     CallHookPkt(Handle -> HelpHook,&Message,&Box);
  305.                 }
  306.  
  307.                 if(Handle -> RawKeyFilter)
  308.                     *MsgClass = NULL;
  309.  
  310.                 break;
  311.             }
  312.  
  313.             if((*MsgCode >= 99 && *MsgCode <= 103) || *MsgCode == 96 || *MsgCode == 97)
  314.             {
  315.                 if(Handle -> RawKeyFilter)
  316.                     *MsgClass = NULL;
  317.  
  318.                 break;
  319.             }
  320.  
  321.             event . ie_NextEvent        = NULL;
  322.             event . ie_Code         = (*MsgCode) & ~IECODE_UP_PREFIX;
  323.             event . ie_Qualifier        = MsgQualifier & ~QUALIFIER_SHIFT;
  324.             event . ie_Class        = IECLASS_RAWKEY;
  325.             event . ie_SubClass        = 0;
  326.             event . ie_position . ie_addr    = (APTR)*MsgGadget;
  327.  
  328.             Buffer[0] = 0;
  329.  
  330.             if(MapRawKey(&event,Buffer,9,NULL) < 1)
  331.             {
  332.                 if(Handle -> RawKeyFilter)
  333.                     *MsgClass = NULL;
  334.  
  335.                 break;
  336.             }
  337.  
  338.             if(!(Key = Buffer[0]))
  339.             {
  340.                 if(Handle -> RawKeyFilter)
  341.                     *MsgClass = NULL;
  342.  
  343.                 break;
  344.             }
  345.  
  346.             if((*MsgCode) & IECODE_UP_PREFIX)
  347.                 KeyUp = TRUE;
  348.             else
  349.                 KeyUp = FALSE;
  350.  
  351.             if(!KeyUp && Handle -> CursorKey && (*MsgCode == CURSORUP || *MsgCode == CURSORDOWN))
  352.             {
  353.                 ObjectNode    *Node;
  354.                 struct Gadget    *Gadget;
  355.                 LONG         NewState;
  356.  
  357.                 Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  358.  
  359.                 Node        = Handle -> CursorKey;
  360.                 Gadget        = Node -> Host;
  361.                 NewState    = Node -> Current;
  362.  
  363.                 if(*MsgCode == CURSORDOWN)
  364.                 {
  365.                     if(MsgQualifier & QUALIFIER_SHIFT)
  366.                         NewState += Node -> Lines;
  367.                     else
  368.                     {
  369.                         if(MsgQualifier & (QUALIFIER_ALT | QUALIFIER_CONTROL))
  370.                             NewState = Node -> Max;
  371.                         else
  372.                             NewState++;
  373.                     }
  374.                 }
  375.                 else
  376.                 {
  377.                     if(MsgQualifier & QUALIFIER_SHIFT)
  378.                         NewState -= Node -> Lines;
  379.                     else
  380.                     {
  381.                         if(MsgQualifier & (QUALIFIER_ALT | QUALIFIER_CONTROL))
  382.                             NewState = Node -> Min;
  383.                         else
  384.                             NewState--;
  385.                     }
  386.                 }
  387.  
  388.                 if(NewState < Node -> Min)
  389.                     NewState = Node -> Min;
  390.                 else
  391.                 {
  392.                     if(NewState > Node -> Max)
  393.                         NewState = Node -> Max;
  394.                 }
  395.  
  396.                 if(NewState != Node -> Current || Node -> Max == Node -> Min)
  397.                 {
  398.                     Node -> Current = NewState;
  399.  
  400.                     GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  401.                         GTLV_Top,        Node -> Current,
  402.                         GTLV_MakeVisible,    Node -> Current,
  403.  
  404.                         Node -> Special . List . LinkID != -1 ? GTLV_Selected : TAG_IGNORE,Node -> Current,
  405.                     TAG_DONE);
  406.  
  407.                     LTP_PutStorage(Node);
  408.  
  409.                     *MsgClass    = IDCMP_GADGETUP;
  410.                     *MsgCode    = Node -> Current;
  411.                     *MsgGadget    = Gadget;
  412.  
  413.                     if(!LTP_NotifyPager(Handle,Node->Special.List.AutoPageID,Node->Current))
  414.                         *MsgClass = IDCMP_CLOSEWINDOW;
  415.                 }
  416.                 else
  417.                 {
  418.                     if(Handle -> RawKeyFilter)
  419.                         *MsgClass = NULL;
  420.                 }
  421.  
  422.                 Handle->ActiveFrame = NULL;
  423.  
  424.                 return;
  425.             }
  426.  
  427.             if(Key == '\t' && !KeyUp)
  428.             {
  429.                 ObjectNode *Node;
  430.  
  431.                 if(Handle -> RawKeyFilter)
  432.                     *MsgClass = NULL;
  433.  
  434.                 if(Node = Handle -> TabKey)
  435.                 {
  436.                     if(!(Node -> Disabled))
  437.                     {
  438.                         LONG Choice;
  439.  
  440.                         if(MsgQualifier & QUALIFIER_SHIFT)
  441.                             Choice = Node -> Current - 1;
  442.                         else
  443.                             Choice = Node -> Current + 1;
  444.  
  445.                         if(Choice < Node -> Min)
  446.                             Choice = Node -> Max;
  447.                         else
  448.                         {
  449.                             if(Choice > Node -> Max)
  450.                                 Choice = Node -> Min;
  451.                         }
  452.  
  453.                         if(Choice != Node -> Current)
  454.                         {
  455.                             LONG AutoPageID,Type;
  456.                             BOOL CanBlink;
  457.  
  458.                             *MsgClass = IDCMP_GADGETUP;
  459.  
  460.                             CanBlink = FALSE;
  461.  
  462.                             switch(Node -> Type)
  463.                             {
  464.                                 case CYCLE_KIND:
  465.  
  466.                                     AutoPageID    = Node -> Special . Cycle . AutoPageID;
  467.                                     Type        = GTCY_Active;
  468.                                     CanBlink    = TRUE;
  469.                                     break;
  470. #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
  471.                                 case POPUP_KIND:
  472.  
  473.                                     AutoPageID    = Node -> Special . Popup . AutoPageID;
  474.                                     Type        = LAPU_Active;
  475.                                     CanBlink    = TRUE;
  476.                                     break;
  477. #endif
  478. #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
  479.                                 case TAB_KIND:
  480.  
  481.                                     AutoPageID    = Node -> Special . Tab . AutoPageID;
  482.                                     Type        = LATB_Active;
  483.                                     break;
  484. #endif
  485.                                 case MX_KIND:
  486.  
  487.                                     AutoPageID    = Node -> Special . Radio . AutoPageID;
  488.                                     Type        = GTMX_Active;
  489.  
  490.                                     *MsgClass = IDCMP_GADGETDOWN;
  491.  
  492.                                     break;
  493.                             }
  494.  
  495.                             *MsgCode    = (UWORD)Choice;
  496.                             *MsgGadget    = Node -> Host;
  497.  
  498.                             if(CanBlink)
  499.                                 LTP_BlinkButton(Handle,*MsgGadget);
  500.  
  501.                             LT_SetAttributes(Handle,Node -> ID,
  502.                                 Type,Choice,
  503.                             TAG_DONE);
  504.  
  505.                             if(!LTP_NotifyPager(Handle,AutoPageID,Choice))
  506.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  507.                         }
  508.                     }
  509.                 }
  510.  
  511.                 Handle->ActiveFrame = NULL;
  512.  
  513.                 return;
  514.             }
  515.  
  516.             if(Key == '\33' && !KeyUp)
  517.             {
  518.                 ObjectNode *Node;
  519.  
  520.                 Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  521.  
  522.                 if(Node = Handle -> EscKey)
  523.                 {
  524.                     if(!Node -> Disabled)
  525.                     {
  526.                         LTP_BlinkButton(Handle,Node -> Host);
  527.  
  528.                         *MsgCode    = 0;
  529.                         *MsgGadget    = Node -> Host;
  530.                         *MsgClass    = IDCMP_GADGETUP;
  531.                     }
  532.                     else
  533.                     {
  534.                         if(Handle -> RawKeyFilter)
  535.                             *MsgClass = NULL;
  536.                     }
  537.                 }
  538.                 else
  539.                 {
  540.                     if(Handle -> Window -> Flags & WFLG_CLOSEGADGET)
  541.                     {
  542.                         *MsgCode    = 0;
  543.                         *MsgGadget    = NULL;
  544.                         *MsgClass    = IDCMP_CLOSEWINDOW;
  545.                     }
  546.                     else
  547.                     {
  548.                         if(Handle -> RawKeyFilter)
  549.                             *MsgClass = NULL;
  550.                     }
  551.                 }
  552.  
  553.                 Handle->ActiveFrame = NULL;
  554.  
  555.                 return;
  556.             }
  557.             else
  558.             {
  559.                 struct Gadget    *Gadget;
  560.                 ObjectNode    *Node;
  561.                 LONG         i;
  562.                 BOOL          FoundIt = FALSE,
  563.                          Forward;
  564.  
  565.                 if(MsgQualifier & QUALIFIER_SHIFT)
  566.                     Forward = FALSE;
  567.                 else
  568.                     Forward = TRUE;
  569.  
  570.                 if(Handle -> ReturnKey && Key == '\r')
  571.                 {
  572.                     Node = Handle -> ReturnKey;
  573.  
  574.                     if(!KeyUp && !Node -> Disabled)
  575.                     {
  576.                         LTP_BlinkButton(Handle,Node -> Host);
  577.  
  578.                         *MsgClass    = IDCMP_GADGETUP;
  579.                         *MsgCode    = 0;
  580.                         *MsgGadget    = Node -> Host;
  581.                     }
  582.                     else
  583.                     {
  584.                         if(Handle -> RawKeyFilter)
  585.                             *MsgClass = NULL;
  586.                     }
  587.  
  588.                     Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  589.  
  590.                     Handle->ActiveFrame = NULL;
  591.  
  592.                     return;
  593.                 }
  594.  
  595.                 for(i = 0 ; !FoundIt && i < Handle -> Count ; i++)
  596.                 {
  597.                     if(Gadget = Handle -> GadgetArray[i])
  598.                     {
  599.                         if(GETOBJECT(Gadget,Node))
  600.                         {
  601.                             if(Key == Node -> Key)
  602.                             {
  603.                                 if(Node -> Disabled)
  604.                                     break;
  605.                                 else
  606.                                 {
  607.                                     switch(Node -> Type)
  608.                                     {
  609. #ifdef DO_BOOPSI_KIND
  610.                                         case BOOPSI_KIND:
  611.  
  612.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  613.                                             {
  614.                                                 if(Node -> Special . BOOPSI . ActivateHook)
  615.                                                 {
  616.                                                     if(CallHookPkt(Node -> Special . BOOPSI . ActivateHook,(APTR)Handle,(APTR)Node -> Host))
  617.                                                     {
  618.                                                         if(Handle -> RawKeyFilter)
  619.                                                             *MsgClass = NULL;
  620.  
  621.                                                         break;
  622.                                                     }
  623.                                                 }
  624.  
  625.                                                 *MsgClass    = IDCMP_GADGETUP;
  626.                                                 *MsgCode    = (MsgQualifier & QUALIFIER_SHIFT) ? -1 : 1;
  627.                                                 *MsgGadget    = Gadget;
  628.                                             }
  629.                                             else
  630.                                             {
  631.                                                 if(Handle -> RawKeyFilter)
  632.                                                     *MsgClass = NULL;
  633.                                             }
  634.  
  635.                                             break;
  636. #ifdef DO_POPUP_KIND
  637.                                         case POPUP_KIND:
  638.  
  639.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  640.                                             {
  641.                                                 LONG Choice;
  642.  
  643.                                                 if(MsgQualifier & QUALIFIER_SHIFT)
  644.                                                     Choice = Node -> Current - 1;
  645.                                                 else
  646.                                                     Choice = Node -> Current + 1;
  647.  
  648.                                                 if(Choice < Node -> Min)
  649.                                                     Choice = Node -> Max;
  650.                                                 else
  651.                                                 {
  652.                                                     if(Choice > Node -> Max)
  653.                                                         Choice = Node -> Min;
  654.                                                 }
  655.  
  656.                                                 if(Choice != Node -> Current)
  657.                                                 {
  658.                                                     LTP_BlinkButton(Handle,Node -> Host);
  659.  
  660.                                                     *MsgClass    = IDCMP_GADGETUP;
  661.                                                     *MsgCode    = (UWORD)Choice;
  662.                                                     *MsgGadget    = Node -> Host;
  663.  
  664.                                                     LT_SetAttributes(Handle,0,
  665.                                                         LAPR_Gadget,    Node -> Host,
  666.                                                         LAPU_Active,    Choice,
  667.                                                     TAG_DONE);
  668.                                                 }
  669.                                             }
  670.                                             else
  671.                                             {
  672.                                                 if(Handle -> RawKeyFilter)
  673.                                                     *MsgClass = NULL;
  674.                                             }
  675.  
  676.                                             break;
  677. #endif    // DO_POPUP_KIND
  678.  
  679. #ifdef DO_TAB_KIND
  680.                                         case TAB_KIND:
  681.  
  682.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  683.                                             {
  684.                                                 LONG Choice;
  685.  
  686.                                                 if(MsgQualifier & QUALIFIER_SHIFT)
  687.                                                     Choice = Node -> Current - 1;
  688.                                                 else
  689.                                                     Choice = Node -> Current + 1;
  690.  
  691.                                                 if(Choice < Node -> Min)
  692.                                                     Choice = Node -> Max;
  693.                                                 else
  694.                                                 {
  695.                                                     if(Choice > Node -> Max)
  696.                                                         Choice = Node -> Min;
  697.                                                 }
  698.  
  699.                                                 if(Choice != Node -> Current)
  700.                                                 {
  701.                                                     *MsgClass    = IDCMP_GADGETUP;
  702.                                                     *MsgCode    = (UWORD)Choice;
  703.                                                     *MsgGadget    = Node -> Host;
  704.  
  705.                                                     LT_SetAttributes(Handle,0,
  706.                                                         LAPR_Gadget,    Node -> Host,
  707.                                                         LAPU_Active,    Choice,
  708.                                                     TAG_DONE);
  709.                                                 }
  710.                                             }
  711.                                             else
  712.                                             {
  713.                                                 if(Handle -> RawKeyFilter)
  714.                                                     *MsgClass = NULL;
  715.                                             }
  716.  
  717.                                             break;
  718. #endif    // DO_TAB_KIND
  719. #endif    /* DO_BOOPSI_KIND */
  720. #ifdef DO_TAPEDECK_KIND
  721.                                         case TAPEDECK_KIND:
  722.  
  723.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  724.                                             {
  725.                                                 if(Node -> Special . TapeDeck . Toggle)
  726.                                                 {
  727.                                                     LT_SetAttributes(Handle,Node -> ID,
  728.                                                         LAPR_Object,    Node,
  729.                                                         LATD_Pressed,    !Node -> Current,
  730.                                                     TAG_DONE);
  731.  
  732.                                                     LTP_PutStorage(Node);
  733.                                                 }
  734.                                                 else
  735.                                                     LTP_BlinkButton(Handle,Gadget);
  736.  
  737.                                                 if(Gadget -> Flags & GFLG_SELECTED)
  738.                                                     *MsgCode = TRUE;
  739.                                                 else
  740.                                                     *MsgCode = FALSE;
  741.  
  742.                                                 *MsgClass    = IDCMP_GADGETUP;
  743.                                                 *MsgGadget    = Gadget;
  744.                                             }
  745.                                             else
  746.                                             {
  747.                                                 if(Handle -> RawKeyFilter)
  748.                                                     *MsgClass = NULL;
  749.                                             }
  750.  
  751.                                             break;
  752. #endif    /* DO_TAPEDECK_KIND */
  753.                                         case CHECKBOX_KIND:
  754.  
  755.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  756.                                             {
  757.                                                 Node -> Current = !Node -> Current;
  758.  
  759.                                                 LTP_PutStorage(Node);
  760.  
  761.                                                 GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  762.                                                     GTCB_Checked,Node -> Current,
  763.                                                 TAG_DONE);
  764.  
  765.                                                 *MsgClass    = IDCMP_GADGETUP;
  766.                                                 *MsgCode    = Node -> Current;
  767.                                                 *MsgGadget    = Gadget;
  768.                                             }
  769.                                             else
  770.                                             {
  771.                                                 if(Handle -> RawKeyFilter)
  772.                                                     *MsgClass = NULL;
  773.                                             }
  774.  
  775.                                             FoundIt = TRUE;
  776.  
  777.                                             break;
  778.  
  779.                                         case LISTVIEW_KIND:
  780.  
  781.                                             if(!KeyUp)
  782.                                             {
  783.                                                 BOOL setAttrs = FALSE;
  784.  
  785.                                                 if(Forward)
  786.                                                 {
  787.                                                     if(Node -> Current < Node -> Max)
  788.                                                     {
  789.                                                         Node -> Current++;
  790.  
  791.                                                         setAttrs = TRUE;
  792.                                                     }
  793.                                                 }
  794.                                                 else
  795.                                                 {
  796.                                                     if(Node -> Current > Node -> Min)
  797.                                                     {
  798.                                                         Node -> Current--;
  799.  
  800.                                                         setAttrs = TRUE;
  801.                                                     }
  802.                                                 }
  803.  
  804.                                                 if(setAttrs)
  805.                                                 {
  806.                                                     if(Node -> Current < 0)
  807.                                                     {
  808.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  809.                                                             GTLV_Selected,Node -> Current,
  810.                                                         TAG_DONE);
  811.                                                     }
  812.                                                     else
  813.                                                     {
  814.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  815.                                                             GTLV_Top,        Node -> Current,
  816.                                                             GTLV_MakeVisible,    Node -> Current,
  817.                                                             Node -> Special . List . LinkID != -1 ? GTLV_Selected : TAG_IGNORE,Node -> Current,
  818.                                                         TAG_DONE);
  819.                                                     }
  820.  
  821.                                                     LTP_PutStorage(Node);
  822.  
  823.                                                     *MsgClass    = IDCMP_GADGETUP;
  824.                                                     *MsgCode    = Node -> Current;
  825.                                                     *MsgGadget    = Gadget;
  826.  
  827.                                                     if(!LTP_NotifyPager(Handle,Node->Special.List.AutoPageID,Node->Current))
  828.                                                         *MsgClass = IDCMP_CLOSEWINDOW;
  829.                                                 }
  830.                                                 else
  831.                                                 {
  832.                                                     if(Handle -> RawKeyFilter)
  833.                                                         *MsgClass = NULL;
  834.                                                 }
  835.                                             }
  836.                                             else
  837.                                             {
  838.                                                 if(Handle -> RawKeyFilter)
  839.                                                     *MsgClass = NULL;
  840.                                             }
  841.  
  842.                                             FoundIt = TRUE;
  843.  
  844.                                             break;
  845.  
  846.                                         case MX_KIND:
  847.  
  848.                                             if(!KeyUp)
  849.                                             {
  850.                                                 if(Forward)
  851.                                                 {
  852.                                                     if(Node -> Current < Node -> Max)
  853.                                                     {
  854.                                                         Node -> Current++;
  855.  
  856.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  857.                                                             GTMX_Active,Node -> Current,
  858.                                                         TAG_DONE);
  859.  
  860.                                                         LTP_PutStorage(Node);
  861.  
  862.                                                         *MsgClass    = IDCMP_GADGETDOWN;
  863.                                                         *MsgCode    = Node -> Current;
  864.                                                         *MsgGadget    = Gadget;
  865.                                                     }
  866.                                                     else
  867.                                                     {
  868.                                                         if(Handle -> RawKeyFilter)
  869.                                                             *MsgClass = NULL;
  870.                                                     }
  871.                                                 }
  872.                                                 else
  873.                                                 {
  874.                                                     if(Node -> Current > Node -> Min)
  875.                                                     {
  876.                                                         Node -> Current--;
  877.  
  878.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  879.                                                             GTMX_Active,Node -> Current,
  880.                                                         TAG_DONE);
  881.  
  882.                                                         LTP_PutStorage(Node);
  883.  
  884.                                                         *MsgClass    = IDCMP_GADGETDOWN;
  885.                                                         *MsgCode    = Node -> Current;
  886.                                                         *MsgGadget    = Gadget;
  887.                                                     }
  888.                                                     else
  889.                                                         *MsgClass = NULL;
  890.                                                 }
  891.                                             }
  892.                                             else
  893.                                                 *MsgClass = NULL;
  894.  
  895.                                             if(*MsgClass)
  896.                                             {
  897.                                                 if(Node -> Special . Radio . AutoPageID != -1)
  898.                                                 {
  899.                                                     if(!LTP_NotifyPager(Handle,Node->Special.Radio.AutoPageID,Node->Current))
  900.                                                         *MsgClass = IDCMP_CLOSEWINDOW;
  901.                                                     else
  902.                                                     {
  903.                                                         if(Handle -> RawKeyFilter)
  904.                                                             *MsgClass = NULL;
  905.                                                     }
  906.                                                 }
  907.                                             }
  908.  
  909.                                             FoundIt = TRUE;
  910.  
  911.                                             break;
  912.  
  913.                                         case TEXT_KIND:
  914.  
  915.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  916.                                             {
  917.                                                 if(Node -> Special . Text . Picker)
  918.                                                 {
  919.                                                     LTP_BlinkButton(Handle,Node -> Special . Text . Picker);
  920.  
  921.                                                     *MsgClass    = IDCMP_IDCMPUPDATE;
  922.                                                     *MsgCode    = 0;
  923.                                                     *MsgGadget    = Gadget;
  924.                                                 }
  925.                                                 else
  926.                                                 {
  927.                                                     if(Handle -> RawKeyFilter)
  928.                                                         *MsgClass = NULL;
  929.                                                 }
  930.                                             }
  931.                                             else
  932.                                             {
  933.                                                 if(Handle -> RawKeyFilter)
  934.                                                     *MsgClass = NULL;
  935.                                             }
  936.  
  937.                                             FoundIt = TRUE;
  938.  
  939.                                             break;
  940.  
  941.                                         case NUMBER_KIND:
  942.  
  943.                                             if(Handle -> RawKeyFilter)
  944.                                                 *MsgClass = NULL;
  945.  
  946.                                             FoundIt = TRUE;
  947.  
  948.                                             break;
  949.  
  950.                                         case CYCLE_KIND:
  951.  
  952.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  953.                                             {
  954.                                                 LTP_BlinkButton(Handle,Gadget);
  955.  
  956.                                                 if(Forward)
  957.                                                 {
  958.                                                     if(Node -> Current < Node -> Max)
  959.                                                         Node -> Current++;
  960.                                                     else
  961.                                                         Node -> Current = Node -> Min;
  962.                                                 }
  963.                                                 else
  964.                                                 {
  965.                                                     if(Node -> Current > Node -> Min)
  966.                                                         Node -> Current--;
  967.                                                     else
  968.                                                         Node -> Current = Node -> Max;
  969.                                                 }
  970.  
  971.                                                 LTP_PutStorage(Node);
  972.  
  973.                                                 GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  974.                                                     GTCY_Active,Node -> Current,
  975.                                                 TAG_DONE);
  976.  
  977.                                                 *MsgClass    = IDCMP_GADGETUP;
  978.                                                 *MsgCode    = Node -> Current;
  979.                                                 *MsgGadget    = Gadget;
  980.  
  981.                                                 if(Node -> Special . Cycle . AutoPageID != -1)
  982.                                                 {
  983.                                                     if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  984.                                                         *MsgClass = IDCMP_CLOSEWINDOW;
  985.                                                     else
  986.                                                     {
  987.                                                         if(Handle -> RawKeyFilter)
  988.                                                             *MsgClass = NULL;
  989.                                                     }
  990.                                                 }
  991.                                             }
  992.                                             else
  993.                                             {
  994.                                                 if(Handle -> RawKeyFilter)
  995.                                                     *MsgClass = NULL;
  996.                                             }
  997.  
  998.                                             FoundIt = TRUE;
  999.  
  1000.                                             break;
  1001.  
  1002.                                         case PALETTE_KIND:
  1003.  
  1004.                                             if(!KeyUp)
  1005.                                             {
  1006.                                                 if(Node -> Special . Palette . UsePicker)
  1007.                                                 {
  1008.                                                     if(!(MsgQualifier & IEQUALIFIER_REPEAT))
  1009.                                                     {
  1010.                                                         LTP_BlinkButton(Handle,Node -> Special . Palette . Picker);
  1011.  
  1012.                                                         *MsgClass    = IDCMP_IDCMPUPDATE;
  1013.                                                         *MsgCode    = 0;
  1014.                                                         *MsgGadget    = Gadget;
  1015.                                                     }
  1016.                                                     else
  1017.                                                     {
  1018.                                                         if(Handle -> RawKeyFilter)
  1019.                                                             *MsgClass = NULL;
  1020.                                                     }
  1021.  
  1022.                                                     FoundIt = TRUE;
  1023.  
  1024.                                                     break;
  1025.                                                 }
  1026.  
  1027.                                                 if(Node -> Special . Palette . TranslateBack)
  1028.                                                 {
  1029.                                                     LONG Index = Node -> Special . Palette . TranslateBack[Node -> Current];
  1030.  
  1031.                                                     if(Index < Node -> Min)
  1032.                                                         Index = Node -> Min;
  1033.                                                     else
  1034.                                                     {
  1035.                                                         if(Index > Node -> Max)
  1036.                                                             Index = Node -> Max;
  1037.                                                     }
  1038.  
  1039.                                                     if(Forward)
  1040.                                                     {
  1041.                                                         if(Index < Node -> Max)
  1042.                                                             Index++;
  1043.                                                         else
  1044.                                                             Index = Node -> Min;
  1045.                                                     }
  1046.                                                     else
  1047.                                                     {
  1048.                                                         if(Index > Node -> Min)
  1049.                                                             Index--;
  1050.                                                         else
  1051.                                                             Index = Node -> Max;
  1052.                                                     }
  1053.  
  1054.                                                     if(Index < Node -> Min)
  1055.                                                         Index = Node -> Min;
  1056.                                                     else
  1057.                                                     {
  1058.                                                         if(Index > Node -> Max)
  1059.                                                             Index = Node -> Max;
  1060.                                                     }
  1061.  
  1062.                                                     Node -> Current = Node -> Special . Palette . ColourTable[Index];
  1063.                                                 }
  1064.                                                 else
  1065.                                                 {
  1066.                                                     if(Forward)
  1067.                                                     {
  1068.                                                         if(Node -> Current < Node -> Max)
  1069.                                                             Node -> Current++;
  1070.                                                         else
  1071.                                                             Node -> Current = Node -> Min;
  1072.                                                     }
  1073.                                                     else
  1074.                                                     {
  1075.                                                         if(Node -> Current > Node -> Min)
  1076.                                                             Node -> Current--;
  1077.                                                         else
  1078.                                                             Node -> Current = Node -> Max;
  1079.                                                     }
  1080.                                                 }
  1081.  
  1082.                                                 LTP_PutStorage(Node);
  1083.  
  1084.                                                 GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  1085.                                                     GTPA_Color,Node -> Current,
  1086.                                                 TAG_DONE);
  1087.  
  1088.                                                 *MsgClass    = IDCMP_GADGETUP;
  1089.                                                 *MsgCode    = Node -> Current;
  1090.                                                 *MsgGadget    = Gadget;
  1091.                                             }
  1092.                                             else
  1093.                                             {
  1094.                                                 if(Handle -> RawKeyFilter)
  1095.                                                     *MsgClass = NULL;
  1096.                                             }
  1097.  
  1098.                                             FoundIt = TRUE;
  1099.  
  1100.                                             break;
  1101.  
  1102.                                         case SLIDER_KIND:
  1103.  
  1104.                                             if(KeyUp)
  1105.                                             {
  1106.                                                 *MsgClass    = IDCMP_GADGETUP;
  1107.                                                 *MsgCode    = Node -> Current;
  1108.                                                 *MsgGadget    = Gadget;
  1109.                                             }
  1110.                                             else
  1111.                                             {
  1112.                                                 if(Forward)
  1113.                                                 {
  1114.                                                     if(Node -> Current < Node -> Max)
  1115.                                                     {
  1116.                                                         Node -> Current++;
  1117.  
  1118.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  1119.                                                             GTSL_Level,Node -> Current,
  1120.                                                         TAG_DONE);
  1121.  
  1122.                                                         LTP_PutStorage(Node);
  1123.  
  1124.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  1125.                                                         *MsgCode    = Node -> Current;
  1126.                                                         *MsgGadget    = Gadget;
  1127.                                                     }
  1128.                                                     else
  1129.                                                     {
  1130.                                                         if(Handle -> RawKeyFilter)
  1131.                                                             *MsgClass = NULL;
  1132.                                                     }
  1133.                                                 }
  1134.                                                 else
  1135.                                                 {
  1136.                                                     if(Node -> Current > Node -> Min)
  1137.                                                     {
  1138.                                                         Node -> Current--;
  1139.  
  1140.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  1141.                                                             GTSL_Level,Node -> Current,
  1142.                                                         TAG_DONE);
  1143.  
  1144.                                                         LTP_PutStorage(Node);
  1145.  
  1146.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  1147.                                                         *MsgCode    = Node -> Current;
  1148.                                                         *MsgGadget    = Gadget;
  1149.                                                     }
  1150.                                                     else
  1151.                                                     {
  1152.                                                         if(Handle -> RawKeyFilter)
  1153.                                                             *MsgClass = NULL;
  1154.                                                     }
  1155.                                                 }
  1156.                                             }
  1157.  
  1158.                                             FoundIt = TRUE;
  1159.  
  1160.                                             break;
  1161.  
  1162. #ifdef DO_LEVEL_KIND
  1163.                                         case LEVEL_KIND:
  1164.  
  1165.                                             if(KeyUp)
  1166.                                             {
  1167.                                                 *MsgClass    = IDCMP_GADGETUP;
  1168.                                                 *MsgCode    = Node -> Special . Level . Level;
  1169.                                                 *MsgGadget    = Gadget;
  1170.  
  1171.                                                 LTP_PutStorage(Node);
  1172.                                             }
  1173.                                             else
  1174.                                             {
  1175.                                                 if(Forward)
  1176.                                                 {
  1177.                                                     if(Node -> Special . Level . Level < Node -> Special . Level . Max)
  1178.                                                     {
  1179.                                                         Node -> Special . Level . Level++;
  1180.  
  1181.                                                         LT_SetAttributes(Handle,Node -> ID,
  1182.                                                             LAPR_Object,    Node,
  1183.                                                             LAVL_Level,    Node -> Special . Level . Level,
  1184.                                                         TAG_DONE);
  1185.  
  1186.                                                         LTP_PutStorage(Node);
  1187.  
  1188.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  1189.                                                         *MsgCode    = Node -> Special . Level . Level;
  1190.                                                         *MsgGadget    = Gadget;
  1191.                                                     }
  1192.                                                     else
  1193.                                                     {
  1194.                                                         if(Handle -> RawKeyFilter)
  1195.                                                             *MsgClass = NULL;
  1196.                                                     }
  1197.                                                 }
  1198.                                                 else
  1199.                                                 {
  1200.                                                     if(Node -> Special . Level . Level > Node -> Special . Level . Min)
  1201.                                                     {
  1202.                                                         Node -> Special . Level . Level--;
  1203.  
  1204.                                                         LT_SetAttributes(Handle,Node -> ID,
  1205.                                                             LAPR_Object,    Node,
  1206.                                                             LAVL_Level,    Node -> Special . Level . Level,
  1207.                                                         TAG_DONE);
  1208.  
  1209.                                                         LTP_PutStorage(Node);
  1210.  
  1211.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  1212.                                                         *MsgCode    = Node -> Special . Level . Level;
  1213.                                                         *MsgGadget    = Gadget;
  1214.                                                     }
  1215.                                                     else
  1216.                                                     {
  1217.                                                         if(Handle -> RawKeyFilter)
  1218.                                                             *MsgClass = NULL;
  1219.                                                     }
  1220.                                                 }
  1221.                                             }
  1222.  
  1223.                                             FoundIt = TRUE;
  1224.  
  1225.                                             break;
  1226. #endif    /* DO_LEVEL_KIND */
  1227.                                         case SCROLLER_KIND:
  1228.  
  1229.                                             if(KeyUp)
  1230.                                             {
  1231.                                                 *MsgClass    = IDCMP_GADGETUP;
  1232.                                                 *MsgCode    = Node -> Current;
  1233.                                                 *MsgGadget    = Gadget;
  1234.                                             }
  1235.                                             else
  1236.                                             {
  1237.                                                 if(Forward)
  1238.                                                 {
  1239.                                                     if(Node -> Current < Node -> Max)
  1240.                                                     {
  1241.                                                         Node -> Current++;
  1242.  
  1243.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  1244.                                                             GTSC_Top,Node -> Current,
  1245.                                                         TAG_DONE);
  1246.  
  1247.                                                         LTP_PutStorage(Node);
  1248.  
  1249.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  1250.                                                         *MsgCode    = Node -> Current;
  1251.                                                         *MsgGadget    = Gadget;
  1252.                                                     }
  1253.                                                     else
  1254.                                                     {
  1255.                                                         if(Handle -> RawKeyFilter)
  1256.                                                             *MsgClass = NULL;
  1257.                                                     }
  1258.                                                 }
  1259.                                                 else
  1260.                                                 {
  1261.                                                     if(Node -> Current > Node -> Min)
  1262.                                                     {
  1263.                                                         Node -> Current--;
  1264.  
  1265.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  1266.                                                             GTSC_Top,Node -> Current,
  1267.                                                         TAG_DONE);
  1268.  
  1269.                                                         LTP_PutStorage(Node);
  1270.  
  1271.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  1272.                                                         *MsgCode    = Node -> Current;
  1273.                                                         *MsgGadget    = Gadget;
  1274.                                                     }
  1275.                                                     else
  1276.                                                     {
  1277.                                                         if(Handle -> RawKeyFilter)
  1278.                                                             *MsgClass = NULL;
  1279.                                                     }
  1280.                                                 }
  1281.                                             }
  1282.  
  1283.                                             FoundIt = TRUE;
  1284.  
  1285.                                             break;
  1286.  
  1287.                                         case STRING_KIND:
  1288.                                         case FRACTION_KIND:
  1289.                                         case PASSWORD_KIND:
  1290.  
  1291.                                             if(!KeyUp)
  1292.                                             {
  1293.                                                 if(Node -> Special . String . Picker && !Forward)
  1294.                                                 {
  1295.                                                     LTP_BlinkButton(Handle,Node -> Special . String . Picker);
  1296.  
  1297.                                                     *MsgClass    = IDCMP_IDCMPUPDATE;
  1298.                                                     *MsgCode    = 0;
  1299.                                                     *MsgGadget    = Gadget;
  1300.                                                 }
  1301.                                                 else
  1302.                                                 {
  1303.                                                     ActivateGadget(Gadget,Handle -> Window,NULL);
  1304.  
  1305.                                                     *MsgClass    = IDCMP_GADGETDOWN;
  1306.                                                     *MsgCode    = 0;
  1307.                                                     *MsgGadget    = Gadget;
  1308.  
  1309.                                                     Handle -> Previous = Gadget;
  1310.                                                 }
  1311.                                             }
  1312.                                             else
  1313.                                             {
  1314.                                                 if(Handle -> RawKeyFilter)
  1315.                                                     *MsgClass = NULL;
  1316.                                             }
  1317.  
  1318.                                             FoundIt = TRUE;
  1319.  
  1320.                                             break;
  1321.  
  1322.                                         case INTEGER_KIND:
  1323.  
  1324.                                             if(!KeyUp)
  1325.                                             {
  1326.                                                 if(Node -> Special . Integer . UseIncrementers)
  1327.                                                 {
  1328.                                                     ObjectNode    *incNode,*Parent = (ObjectNode *)Gadget -> UserData;
  1329.                                                     LONG         Number;
  1330.                                                     struct Gadget    *Incrementer;
  1331.  
  1332.                                                     if(Forward)
  1333.                                                     {
  1334.                                                         incNode = Node -> Special . Integer . RightIncrementer -> UserData;
  1335.  
  1336.                                                         Incrementer = Node -> Special . Integer . RightIncrementer;
  1337.                                                     }
  1338.                                                     else
  1339.                                                     {
  1340.                                                         incNode = Node -> Special . Integer . LeftIncrementer -> UserData;
  1341.  
  1342.                                                         Incrementer = Node -> Special . Integer . LeftIncrementer;
  1343.                                                     }
  1344.  
  1345.                                                     if(Parent -> Special . Integer . IncrementerHook)
  1346.                                                         Number = CallHookPkt(Parent -> Special . Integer . IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE),incNode -> Special . Incrementer . Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  1347.                                                     else
  1348.                                                         Number = LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE) + incNode -> Special . Incrementer . Amount;
  1349.  
  1350.                                                     if(Number >= Parent -> Min && Number <= Parent -> Max)
  1351.                                                     {
  1352.                                                         LTP_BlinkButton(Handle,Incrementer);
  1353.  
  1354.                                                         LT_SetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,GTIN_Number,Number,TAG_DONE);
  1355.  
  1356.                                                         *MsgClass = IDCMP_GADGETUP;
  1357.  
  1358.                                                         LTP_PutStorage(Node);
  1359.                                                     }
  1360.                                                 }
  1361.                                                 else
  1362.                                                 {
  1363.                                                     ActivateGadget(Gadget,Handle -> Window,NULL);
  1364.  
  1365.                                                     *MsgClass = IDCMP_GADGETDOWN;
  1366.                                                 }
  1367.  
  1368.                                                 *MsgCode    = 0;
  1369.                                                 *MsgGadget    = Gadget;
  1370.  
  1371.                                                 Handle -> Previous = Gadget;
  1372.                                             }
  1373.                                             else
  1374.                                             {
  1375.                                                 if(Handle -> RawKeyFilter)
  1376.                                                     *MsgClass = NULL;
  1377.                                             }
  1378.  
  1379.                                             FoundIt = TRUE;
  1380.  
  1381.                                             break;
  1382.  
  1383.                                         case BUTTON_KIND:
  1384.  
  1385.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  1386.                                             {
  1387.                                                 LTP_BlinkButton(Handle,Gadget);
  1388.  
  1389.                                                 *MsgClass    = IDCMP_GADGETUP;
  1390.                                                 *MsgCode    = 0;
  1391.                                                 *MsgGadget    = Gadget;
  1392.                                             }
  1393.                                             else
  1394.                                             {
  1395.                                                 if(Handle -> RawKeyFilter)
  1396.                                                     *MsgClass = NULL;
  1397.                                             }
  1398.  
  1399.                                             FoundIt = TRUE;
  1400.  
  1401.                                             break;
  1402.                                     }
  1403.                                 }
  1404.                             }
  1405.                         }
  1406.                     }
  1407.                 }
  1408.  
  1409.                 if(FoundIt)
  1410.                     Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  1411.             }
  1412.  
  1413.             Handle->ActiveFrame = NULL;
  1414.  
  1415.             break;
  1416.         }
  1417.  
  1418.         case IDCMP_GADGETDOWN:
  1419.  
  1420.             if(GETOBJECT((*MsgGadget),Node))
  1421.             {
  1422.                 if(Node -> Type != LISTVIEW_KIND)
  1423.                     Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  1424.  
  1425.                 Handle->ActiveFrame = NULL;
  1426.  
  1427.                 switch(Node -> Type)
  1428.                 {
  1429. #ifdef DO_LEVEL_KIND
  1430.                     case LEVEL_KIND:
  1431.  
  1432.                         Handle -> CurrentLevel = Node;
  1433.  
  1434.                         *MsgCode = Node -> Special . Level . Level;
  1435.  
  1436.                         break;
  1437. #endif    /* DO_LEVEL_KIND */
  1438.                     case STRING_KIND:
  1439.                     case INTEGER_KIND:
  1440.                     case FRACTION_KIND:
  1441.                     case PASSWORD_KIND:
  1442.  
  1443.                         Handle -> Previous = *MsgGadget;
  1444.                         break;
  1445. #ifdef DO_TAPEDECK_KIND
  1446.                     case TAPEDECK_KIND:
  1447.  
  1448.                         if(Node -> Special . TapeDeck . Tick)
  1449.                         {
  1450.                             Handle -> ActiveIncrementer    = Node;
  1451.                             Handle -> IncrementerCountdown    = 2;
  1452.                             Handle -> IncrementerAccelerate    = 10;
  1453.                             Handle -> IncrementerIncrement    = 1;
  1454.  
  1455.                             *MsgClass    = IDCMP_GADGETUP;
  1456.                             *MsgCode    = 0;
  1457.                         }
  1458.                         else
  1459.                         {
  1460.                             if(Node -> Special . TapeDeck . Toggle)
  1461.                             {
  1462.                                 if((*MsgGadget) -> Flags & GFLG_SELECTED)
  1463.                                     *MsgCode = TRUE;
  1464.                                 else
  1465.                                     *MsgCode = FALSE;
  1466.  
  1467.                                 Node -> Current = *MsgCode;
  1468.  
  1469.                                 LTP_PutStorage(Node);
  1470.  
  1471.                                 if(Handle -> Previous && !Node -> PageSelector)
  1472.                                     Activate = TRUE;
  1473.  
  1474.                                 *MsgClass = IDCMP_GADGETUP;
  1475.                             }
  1476.                         }
  1477.  
  1478.                         break;
  1479. #endif    /* DO_TAPEDECK_KIND */
  1480.                     case MX_KIND:
  1481.  
  1482.                         if(!V39 && Node -> Disabled)
  1483.                         {
  1484.                             GT_SetGadgetAttrs(*MsgGadget,Handle -> Window,NULL,
  1485.                                 GTMX_Active,Node -> Current,
  1486.                             TAG_DONE);
  1487.  
  1488.                             *MsgClass = NULL;
  1489.                         }
  1490.                         else
  1491.                         {
  1492.                             Node -> Current = *MsgCode;
  1493.  
  1494.                             LTP_PutStorage(Node);
  1495.  
  1496.                             if(Node -> Special . Radio . AutoPageID != -1)
  1497.                             {
  1498.                                 if(!LTP_NotifyPager(Handle,Node->Special.Radio.AutoPageID,Node->Current))
  1499.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1500.                                 else
  1501.                                     *MsgClass = NULL;
  1502.                             }
  1503.  
  1504.                             if(Handle -> Previous && !Node -> PageSelector)
  1505.                                 Activate = TRUE;
  1506.                         }
  1507.  
  1508.                         break;
  1509.  
  1510.                     case SLIDER_KIND:
  1511.  
  1512.                         if(Node -> Min < 0)
  1513.                             Node -> Current = (WORD)*MsgCode;
  1514.                         else
  1515.                             Node -> Current = *MsgCode;
  1516.  
  1517.                         LTP_PutStorage(Node);
  1518.  
  1519.                         if(Handle -> Previous && !Node -> PageSelector)
  1520.                             Activate = TRUE;
  1521.  
  1522.                         break;
  1523.  
  1524.                     case SCROLLER_KIND:
  1525.  
  1526.                         Node -> Current = *MsgCode;
  1527.  
  1528.                         LTP_PutStorage(Node);
  1529.  
  1530.                         if(Handle -> Previous && !Node -> PageSelector)
  1531.                             Activate = TRUE;
  1532.  
  1533.                         break;
  1534.  
  1535.                     case INCREMENTER_KIND:
  1536.  
  1537.                         Handle -> ActiveIncrementer    = Node;
  1538.                         Handle -> IncrementerCountdown    = 6;
  1539.                         Handle -> IncrementerAccelerate    = 10;
  1540.                         Handle -> IncrementerIncrement    = 1;
  1541.  
  1542.                         *MsgClass    = IDCMP_GADGETUP;
  1543.                         *MsgCode    = 0;
  1544.                         *MsgGadget    = Node -> Special . Incrementer . Parent;
  1545.  
  1546.                         /* ALWAYS */
  1547.                         {
  1548.                             struct ObjectNode    *Parent = (ObjectNode *)(*MsgGadget) -> UserData;
  1549.                             LONG             Number;
  1550.  
  1551.                             if(Parent -> Special . Integer . IncrementerHook)
  1552.                                 Number = CallHookPkt(Parent -> Special . Integer . IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE),Node -> Special . Incrementer . Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  1553.                             else
  1554.                                 Number = LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE) + Node -> Special . Incrementer . Amount;
  1555.  
  1556.                             if(Number >= Parent -> Min && Number <= Parent -> Max)
  1557.                                 LT_SetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,GTIN_Number,Number,TAG_DONE);
  1558.                             else
  1559.                                 *MsgClass = NULL;
  1560.                         }
  1561.  
  1562.                         break;
  1563.                 }
  1564.             }
  1565.  
  1566.             break;
  1567.  
  1568.         case IDCMP_MOUSEBUTTONS:
  1569.         {
  1570.             ObjectNode    *Node;
  1571.             LONG         x,y;
  1572.  
  1573.             x = Handle -> Window -> MouseX;
  1574.             y = Handle -> Window -> MouseY;
  1575.  
  1576.             Node = LTP_FindNode_Position(Handle -> TopGroup,x,y);
  1577.  
  1578.             if(((*MsgCode) & IECODE_UP_PREFIX) && Handle -> Previous)
  1579.                 Activate = TRUE;
  1580.  
  1581.             if(Node && !Node -> Disabled)
  1582.             {
  1583.                 if(*MsgCode == SELECTDOWN)
  1584.                 {
  1585.                     switch(Node -> Type)
  1586.                     {
  1587.                         case CHECKBOX_KIND:
  1588.  
  1589.                             Node -> Current = !Node -> Current;
  1590.  
  1591.                             LTP_PutStorage(Node);
  1592.  
  1593.                             GT_SetGadgetAttrs(Node -> Host,Handle -> Window,NULL,
  1594.                                 GTCB_Checked,Node -> Current,
  1595.                             TAG_DONE);
  1596.  
  1597.                             *MsgClass    = IDCMP_GADGETUP;
  1598.                             *MsgCode    = Node -> Current;
  1599.                             *MsgGadget    = Node -> Host;
  1600.  
  1601.                             break;
  1602.  
  1603.                         case MX_KIND:
  1604.                         {
  1605.                             LONG Index = LTP_Find_Clicked_Item(Handle,Node,x,y);
  1606.  
  1607.                             if(Index != -1)
  1608.                             {
  1609.                                 Node -> Current = Index;
  1610.  
  1611.                                 GT_SetGadgetAttrs(Node -> Host,Handle -> Window,NULL,
  1612.                                     GTMX_Active,Index,
  1613.                                 TAG_DONE);
  1614.  
  1615.                                 LTP_PutStorage(Node);
  1616.  
  1617.                                 *MsgClass    = IDCMP_GADGETDOWN;
  1618.                                 *MsgCode    = Index;
  1619.                                 *MsgGadget    = Node -> Host;
  1620.  
  1621.                                 if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  1622.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1623.                             }
  1624.  
  1625.                             break;
  1626.                         }
  1627.  
  1628.                         case FRAME_KIND:
  1629.  
  1630.                             if(Node->Special.Frame.GenerateEvents)
  1631.                             {
  1632.                                 if(Node->Special.Frame.DrawBox)
  1633.                                 {
  1634.                                     if(x < Node->Left + 2 || x >= Node->Left + Node->Width - 2 || y < Node->Top + 1 || y >= Node->Top + Node->Height - 2)
  1635.                                         break;
  1636.                                 }
  1637.  
  1638.                                 *MsgClass    = IDCMP_GADGETDOWN;
  1639.                                 *MsgGadget    = &Node->Special.Frame.Dummy;
  1640.  
  1641.                                 Handle->ActiveFrame = Node;
  1642.                             }
  1643.  
  1644.                             break;
  1645.                     }
  1646.                 }
  1647.  
  1648.                 if(*MsgCode == SELECTUP)
  1649.                 {
  1650.                         // Now this is a real kludge; as of v37 the
  1651.                         // MX_KIND labels are not part of the gadget
  1652.                         // itself and a plain SELECTDOWN mouse event
  1653.                         // is sent as soon as the user clicks on it.
  1654.                         // This changed with v39 which presumably had
  1655.                         // some code in there to map mouse clicks on
  1656.                         // the gadget labels to proper buttonpress
  1657.                         // events. Now, try as you might the click is
  1658.                         // swallowed and we have to do with the
  1659.                         // SELECTUP, sigh...
  1660.  
  1661.                     if(V39 && Node -> Type == MX_KIND)
  1662.                     {
  1663.                         LONG Index;
  1664.  
  1665.                         Index = LTP_Find_Clicked_Item(Handle,Node,x,y);
  1666.  
  1667.                         if(Index != -1)
  1668.                         {
  1669.                             GT_SetGadgetAttrs(Node -> Host,Handle -> Window,NULL,
  1670.                                 GTMX_Active,Index,
  1671.                             TAG_DONE);
  1672.  
  1673.                             Node -> Current = Index;
  1674.  
  1675.                             LTP_PutStorage(Node);
  1676.  
  1677.                             *MsgClass    = IDCMP_GADGETDOWN;
  1678.                             *MsgCode    = Index;
  1679.                             *MsgGadget    = Node -> Host;
  1680.  
  1681.                             if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  1682.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  1683.                         }
  1684.                     }
  1685.  
  1686.                     if(Handle -> ActiveIncrementer)
  1687.                     {
  1688.                         if(Handle -> ActiveIncrementer -> Type == TAPEDECK_KIND && Handle -> ActiveIncrementer  -> Special . TapeDeck . Tick)
  1689.                         {
  1690.                             Handle -> ActiveIncrementer = NULL;
  1691.  
  1692.                             *MsgClass    = IDCMP_GADGETUP;
  1693.                             *MsgCode    = 1;
  1694.                         }
  1695.                         else
  1696.                         {
  1697.                             if(((ObjectNode *)Handle -> ActiveIncrementer -> Special . Incrementer . Parent -> UserData) -> Type == INTEGER_KIND)
  1698.                             {
  1699.                                 *MsgGadget    = Handle -> ActiveIncrementer -> Special . Incrementer . Parent;
  1700.                                 *MsgClass    = IDCMP_GADGETUP;
  1701.                                 *MsgCode    = 1;
  1702.                             }
  1703.  
  1704.                             Handle -> ActiveIncrementer = NULL;
  1705.                         }
  1706.                     }
  1707.  
  1708.                     if(Handle->ActiveFrame)
  1709.                     {
  1710.                         *MsgClass    = IDCMP_GADGETUP;
  1711.                         *MsgGadget    = &Node->Special.Frame.Dummy;
  1712.  
  1713.                         Handle->ActiveFrame = NULL;
  1714.                     }
  1715.                 }
  1716.             }
  1717.  
  1718.             break;
  1719.         }
  1720.  
  1721.         case IDCMP_GADGETUP:
  1722.  
  1723. #ifdef DO_LEVEL_KIND
  1724.             Handle -> CurrentLevel = NULL;
  1725. #endif    /* DO_LEVEL_KIND */
  1726.  
  1727.             Handle->ActiveFrame = NULL;
  1728.  
  1729.             if(GETOBJECT((*MsgGadget),Node))
  1730.             {
  1731.                 if(Node -> Type != LISTVIEW_KIND)
  1732.                     Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  1733.  
  1734.                 switch(Node -> Type)
  1735.                 {
  1736.                     case FRACTION_KIND:
  1737.  
  1738.                         LT_SetAttributes(Handle,(*MsgGadget) -> GadgetID,LAFC_Number,LT_GetAttributes(Handle,(*MsgGadget) -> GadgetID,TAG_DONE),TAG_DONE);
  1739.  
  1740.                     /* FALLS THROUGH */
  1741.  
  1742.                     case PASSWORD_KIND:
  1743.                     case STRING_KIND:
  1744.  
  1745.                         LTP_PutStorage(Node);
  1746.  
  1747.                         if(*MsgCode == 0x5F && Handle -> HelpHook)
  1748.                         {
  1749.                             struct HelpMsg     Message;
  1750.                             struct IBox     Box;
  1751.  
  1752.                             Message . ObjectID = Node -> ID;
  1753.  
  1754.                             Box . Left    = Node -> Left;
  1755.                             Box . Top    = Node -> Top;
  1756.                             Box . Width    = Node -> Width;
  1757.                             Box . Height    = Node -> Height;
  1758.  
  1759.                             Message . Handle = Handle;
  1760.  
  1761.                             CallHookPkt(Handle -> HelpHook,&Message,&Box);
  1762.  
  1763.                             *MsgClass = NULL;
  1764.                         }
  1765.                         else
  1766.                             Handle -> Previous = NULL;
  1767.  
  1768.                         break;
  1769.  
  1770.                     case INTEGER_KIND:
  1771.                     {
  1772.                         struct StringInfo *StringInfo = (struct StringInfo *)(*MsgGadget) -> SpecialInfo;
  1773.                         LONG Contents = StringInfo -> LongInt;
  1774.  
  1775.                         if(Contents < Node -> Min)
  1776.                             Contents = Node -> Min;
  1777.                         else
  1778.                         {
  1779.                             if(Contents > Node -> Max)
  1780.                                 Contents = Node -> Max;
  1781.                         }
  1782.  
  1783.                         LT_SetAttributes(Handle,(*MsgGadget) -> GadgetID,GTIN_Number,Contents,TAG_DONE);
  1784.  
  1785.                         LTP_PutStorage(Node);
  1786.  
  1787.                         if(*MsgCode == 0x5F && Handle -> HelpHook)
  1788.                         {
  1789.                             struct HelpMsg     Message;
  1790.                             struct IBox     Box;
  1791.  
  1792.                             Message . ObjectID = Node -> ID;
  1793.  
  1794.                             Box . Left    = Node -> Left;
  1795.                             Box . Top    = Node -> Top;
  1796.                             Box . Width    = Node -> Width;
  1797.                             Box . Height    = Node -> Height;
  1798.  
  1799.                             Message . Handle = Handle;
  1800.  
  1801.                             CallHookPkt(Handle -> HelpHook,&Message,&Box);
  1802.  
  1803.                             *MsgClass = NULL;
  1804.                         }
  1805.                         else
  1806.                             Handle -> Previous = NULL;
  1807.  
  1808.                         break;
  1809.                     }
  1810.  
  1811.                     case CHECKBOX_KIND:
  1812.  
  1813.                         if(!V39)
  1814.                         {
  1815.                             if((*MsgGadget) -> Flags & GFLG_SELECTED)
  1816.                                 *MsgCode = TRUE;
  1817.                             else
  1818.                                 *MsgCode = FALSE;
  1819.                         }
  1820.  
  1821.                         Node -> Current = *MsgCode;
  1822.  
  1823.                         LTP_PutStorage(Node);
  1824.  
  1825.                         if(Handle -> Previous && !Node -> PageSelector)
  1826.                             Activate = TRUE;
  1827.  
  1828.                         break;
  1829. #ifdef DO_TAPEDECK_KIND
  1830.                     case TAPEDECK_KIND:
  1831.  
  1832.                         if(Node -> Special . TapeDeck . Tick)
  1833.                         {
  1834.                             Handle -> ActiveIncrementer = NULL;
  1835.  
  1836.                             *MsgClass    = IDCMP_GADGETUP;
  1837.                             *MsgCode    = 1;
  1838.                         }
  1839.                         else
  1840.                         {
  1841.                             if(Node -> Special . TapeDeck . Toggle)
  1842.                             {
  1843.                                 if((*MsgGadget) -> Flags & GFLG_SELECTED)
  1844.                                     *MsgCode = TRUE;
  1845.                                 else
  1846.                                     *MsgCode = FALSE;
  1847.  
  1848.                                 Node -> Current = *MsgCode;
  1849.  
  1850.                                 LTP_PutStorage(Node);
  1851.                             }
  1852.                         }
  1853.  
  1854.                         if(Handle -> Previous && !Node -> PageSelector)
  1855.                             Activate = TRUE;
  1856.  
  1857.                         break;
  1858. #endif    /* DO_TAPEDECK_KIND */
  1859. #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
  1860.                     case POPUP_KIND:
  1861.  
  1862.                         Node -> Current = *MsgCode;
  1863.  
  1864.                         LTP_PutStorage(Node);
  1865.  
  1866.                         if(Handle -> Previous && !Node -> PageSelector)
  1867.                             Activate = TRUE;
  1868.  
  1869.                         if(Node -> Special . Popup . AutoPageID != -1)
  1870.                         {
  1871.                             if(!LTP_NotifyPager(Handle,Node->Special.Popup.AutoPageID,Node->Current))
  1872.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  1873.                             else
  1874.                                 *MsgClass = NULL;
  1875.                         }
  1876.  
  1877.                         break;
  1878. #endif
  1879.  
  1880. #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
  1881.                     case TAB_KIND:
  1882.  
  1883.                         Node -> Current = *MsgCode;
  1884.  
  1885.                         LTP_PutStorage(Node);
  1886.  
  1887.                         if(Handle -> Previous && !Node -> PageSelector)
  1888.                             Activate = TRUE;
  1889.  
  1890.                         if(Node -> Special . Tab . AutoPageID != -1)
  1891.                         {
  1892.                             if(!LTP_NotifyPager(Handle,Node->Special.Tab.AutoPageID,Node->Current))
  1893.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  1894.                             else
  1895.                                 *MsgClass = NULL;
  1896.                         }
  1897.  
  1898.                         break;
  1899. #endif
  1900.                     case CYCLE_KIND:
  1901.  
  1902.                         Node -> Current = *MsgCode;
  1903.  
  1904.                         LTP_PutStorage(Node);
  1905.  
  1906.                         if(Handle -> Previous && !Node -> PageSelector)
  1907.                             Activate = TRUE;
  1908.  
  1909.                         if(Node -> Special . Cycle . AutoPageID != -1)
  1910.                         {
  1911.                             if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  1912.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  1913.                             else
  1914.                                 *MsgClass = NULL;
  1915.                         }
  1916.  
  1917.                         break;
  1918.  
  1919.                     case PALETTE_KIND:
  1920.  
  1921.                         Node -> Current = *MsgCode;
  1922.  
  1923.                         LTP_PutStorage(Node);
  1924.  
  1925.                         if(Handle -> Previous && !Node -> PageSelector)
  1926.                             Activate = TRUE;
  1927.  
  1928.                         break;
  1929.  
  1930.                     case MX_KIND:
  1931.  
  1932.                         if(!V39 && Node -> Disabled)
  1933.                         {
  1934.                             GT_SetGadgetAttrs(*MsgGadget,Handle -> Window,NULL,
  1935.                                 GTMX_Active,Node -> Current,
  1936.                             TAG_DONE);
  1937.  
  1938.                             *MsgClass = NULL;
  1939.                         }
  1940.                         else
  1941.                         {
  1942.                             Node -> Current = *MsgCode;
  1943.  
  1944.                             LTP_PutStorage(Node);
  1945.  
  1946.                             if(Node -> Special . Radio . AutoPageID != -1)
  1947.                             {
  1948.                                 if(!LTP_NotifyPager(Handle,Node->Special.Radio.AutoPageID,Node->Current))
  1949.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1950.                                 else
  1951.                                     *MsgClass = NULL;
  1952.                             }
  1953.  
  1954.                             if(Handle -> Previous && !Node -> PageSelector)
  1955.                                 Activate = TRUE;
  1956.                         }
  1957.  
  1958.                         break;
  1959.  
  1960.                     case SLIDER_KIND:
  1961.  
  1962.                         if(Node -> Min < 0)
  1963.                             Node -> Current = (WORD)*MsgCode;
  1964.                         else
  1965.                             Node -> Current = *MsgCode;
  1966.  
  1967.                         LTP_PutStorage(Node);
  1968.  
  1969.                         if(Handle -> Previous && !Node -> PageSelector)
  1970.                             Activate = TRUE;
  1971.  
  1972.                         break;
  1973. #ifdef DO_LEVEL_KIND
  1974.                     case LEVEL_KIND:
  1975.  
  1976.                         *MsgCode    = Node -> Special . Level . Level;
  1977.                         *MsgGadget    = Node -> Host;
  1978.  
  1979.                         LTP_PutStorage(Node);
  1980.  
  1981.                         break;
  1982. #endif    /* DO_LEVEL_KIND */
  1983.                     case SCROLLER_KIND:
  1984.  
  1985.                         Node -> Current = *MsgCode;
  1986.  
  1987.                         LTP_PutStorage(Node);
  1988.  
  1989.                         if(Handle -> Previous && !Node -> PageSelector)
  1990.                             Activate = TRUE;
  1991.  
  1992.                         break;
  1993.  
  1994.                     case PICKER_KIND:
  1995.  
  1996.                         *MsgClass    = IDCMP_IDCMPUPDATE;
  1997.                         *MsgCode    = 0;
  1998.                         *MsgGadget    = Node -> Special . Picker . Parent;
  1999.  
  2000.                         if(Handle -> Previous && !Node -> PageSelector)
  2001.                             Activate = TRUE;
  2002.  
  2003.                         break;
  2004.  
  2005.                     case INCREMENTER_KIND:
  2006.  
  2007.                         if(((ObjectNode *)Handle -> ActiveIncrementer -> Special . Incrementer . Parent -> UserData) -> Type == INTEGER_KIND)
  2008.                         {
  2009.                             *MsgGadget    = Handle -> ActiveIncrementer -> Special . Incrementer . Parent;
  2010.                             *MsgClass    = IDCMP_GADGETUP;
  2011.                             *MsgCode    = 1;
  2012.                         }
  2013.  
  2014.                         Handle -> ActiveIncrementer = NULL;
  2015.                         break;
  2016.  
  2017.                     case LISTVIEW_KIND:
  2018.  
  2019.                         if(Node -> Current != *MsgCode || Node != Handle -> ClickObject)
  2020.                         {
  2021.                             CurrentTime(&Handle -> ClickSeconds,&Handle -> ClickMicros);
  2022.  
  2023.                             Handle -> ClickObject = Node;
  2024.                         }
  2025.                         else
  2026.                         {
  2027.                             ULONG Seconds,Micros;
  2028.  
  2029.                             CurrentTime(&Seconds,&Micros);
  2030.  
  2031.                             if(DoubleClick(Handle -> ClickSeconds,Handle -> ClickMicros,Seconds,Micros))
  2032.                                 *MsgClass = IDCMP_IDCMPUPDATE;
  2033.  
  2034.                             Handle -> ClickSeconds    = Seconds;
  2035.                             Handle -> ClickMicros    = Micros;
  2036.                         }
  2037.  
  2038.                         Node -> Current = *MsgCode;
  2039.  
  2040.                         LTP_PutStorage(Node);
  2041.  
  2042.                         if(!LTP_NotifyPager(Handle,Node->Special.List.AutoPageID,Node->Current))
  2043.                             *MsgClass = IDCMP_CLOSEWINDOW;
  2044.  
  2045.                         if(Node -> Special . List . Link)
  2046.                         {
  2047.                             Handle -> Previous = Node -> Special . List . Link;
  2048.  
  2049.                             if(!Node -> PageSelector)
  2050.                                 Activate = TRUE;
  2051.                         }
  2052.                         else
  2053.                         {
  2054.                             if(Handle -> Previous && !Node -> PageSelector)
  2055.                                 Activate = TRUE;
  2056.                         }
  2057.  
  2058.                         break;
  2059.  
  2060.                     default:
  2061.  
  2062.                         if(Handle -> Previous && !Node -> PageSelector)
  2063.                             Activate = TRUE;
  2064.  
  2065.                         break;
  2066.                 }
  2067.             }
  2068.  
  2069.             break;
  2070.  
  2071.         case IDCMP_MOUSEMOVE:
  2072.  
  2073. #ifdef DO_LEVEL_KIND
  2074.             if(Handle -> CurrentLevel)
  2075.                 Node = Handle -> CurrentLevel;
  2076.             else
  2077. #endif
  2078.                 GETOBJECT((*MsgGadget),Node);
  2079.  
  2080.             if(Node)
  2081.             {
  2082.                 if(Node -> Type != LISTVIEW_KIND)
  2083.                     Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  2084.  
  2085.                 switch(Node -> Type)
  2086.                 {
  2087.                     case SCROLLER_KIND:
  2088.  
  2089.                         Node -> Current = *MsgCode;
  2090.  
  2091.                         LTP_PutStorage(Node);
  2092.  
  2093.                         break;
  2094.  
  2095.                     case SLIDER_KIND:
  2096.  
  2097.                         if(Node -> Min < 0)
  2098.                             Node -> Current = (WORD)*MsgCode;
  2099.                         else
  2100.                             Node -> Current = *MsgCode;
  2101.  
  2102.                         LTP_PutStorage(Node);
  2103.  
  2104.                         break;
  2105. #ifdef DO_LEVEL_KIND
  2106.                     case LEVEL_KIND:
  2107.  
  2108.                         *MsgCode    = Node -> Special . Level . Level;
  2109.                         *MsgGadget      = Node -> Host;
  2110.  
  2111.                         LTP_PutStorage(Node);
  2112.  
  2113.                         break;
  2114. #endif    /* DO_LEVEL_KIND */
  2115.                 }
  2116.             }
  2117.  
  2118.             break;
  2119.  
  2120.         case IDCMP_ACTIVEWINDOW:
  2121.  
  2122.             if(Handle -> Previous)
  2123.             {
  2124.                 Activate = TRUE;
  2125.  
  2126.                 *MsgClass    = IDCMP_GADGETDOWN;
  2127.                 *MsgCode    = 0;
  2128.                 *MsgGadget    = Handle -> Previous;
  2129.             }
  2130.  
  2131.             break;
  2132.  
  2133.         case IDCMP_INACTIVEWINDOW:
  2134.  
  2135.             Handle -> ActiveIncrementer = NULL;
  2136.             Handle -> ActiveFrame = NULL;
  2137.             break;
  2138.     }
  2139.  
  2140.     if(Handle -> AutoActivate && Activate && Handle -> Previous)
  2141.     {
  2142.         if(GETOBJECT(Handle -> Previous,Node))
  2143.         {
  2144.             if(!Node -> Disabled)
  2145.             {
  2146.                 if(Node -> Type == BOOPSI_KIND)
  2147.                 {
  2148.                     if(Node -> Special . BOOPSI . ActivateHook)
  2149.                         CallHookPkt(Node -> Special . BOOPSI . ActivateHook,(APTR)Handle,(APTR)Node -> Host);
  2150.                 }
  2151.                 else
  2152.                     ActivateGadget(Handle -> Previous,Handle -> Window,NULL);
  2153.             }
  2154.         }
  2155.     }
  2156. }
  2157.